package com.cloudy.ec2.request;

public class RunInstances extends EC2Request {
	public enum InstanceType{
		M1SMALL("m1.small"),
		M1LARGE("m1.large"),
		M1XLARGE("m1.xlarge"),
		C1MEDIUM("c1.medium"),
		C1XLARGE("c1.xlarge"),
        M24XLARGE("m2.4xlarge"),
        M22XLARGE("m2.2xlarge"),
        M2XLARGE("m2.xlarge");
        private final String value;
		InstanceType(String value){
			this.value = value;
		}
		@Override
		public String toString() {
			return value;
		}
    }
	

	public RunInstances(String imageId, int minCount, int maxCount) {
		putAttribute("ImageId", imageId);
		putAttribute("MinCount", String.valueOf(minCount));
		putAttribute("MaxCount", String.valueOf(maxCount));
		putAttribute("InstanceType", InstanceType.M1SMALL.toString());
	}
	public RunInstances keyName(String keyName){
		putAttribute("KeyName", keyName);
		return this;
	}
	public RunInstances securityGroup(String...securityGroups){
		addAttributes("SecurityGroup", securityGroups);
		return this;
	}
	public RunInstances userData(String userData){
		putAttribute("UserData", userData);
		return this;	
	}
	public RunInstances instanceType(InstanceType instanceType){
		putAttribute("InstanceType", instanceType.toString());
		return this;
	}
	public RunInstances placementAvailabilityZone(String availabilityZone){
		putAttribute("Placement.AvailabilityZone", availabilityZone);
		return this;
	}
	public RunInstances kernelId(String kernelId){
		putAttribute("KernelId", kernelId);
		return this;
	}
	public RunInstances ramdiskId(String ramdiskId){
		putAttribute("RamdiskId", ramdiskId);
		return this;
	}
	public RunInstances blockDeviceMapping(String virtualName, String deviceName){
		putAttribute("BlockDeviceMapping.n.VirtualName", virtualName);
		putAttribute("BlockDeviceMapping.n.DeviceName", deviceName);
		return this;
	}
}
